<?php


/**
 * Base class that represents a query for the 'car_data' table.
 *
 *
 *
 * @method DamagesCarDataQuery orderById($order = Criteria::ASC) Order by the id column
 * @method DamagesCarDataQuery orderByDealerId($order = Criteria::ASC) Order by the dealer_id column
 * @method DamagesCarDataQuery orderByDealerParentId($order = Criteria::ASC) Order by the dealer_parent_id column
 * @method DamagesCarDataQuery orderByDictBrandId($order = Criteria::ASC) Order by the dict_brand_id column
 * @method DamagesCarDataQuery orderByName($order = Criteria::ASC) Order by the name column
 * @method DamagesCarDataQuery orderByComissionNo($order = Criteria::ASC) Order by the comission_no column
 * @method DamagesCarDataQuery orderByVin($order = Criteria::ASC) Order by the vin column
 * @method DamagesCarDataQuery orderByLocked($order = Criteria::ASC) Order by the locked column
 * @method DamagesCarDataQuery orderByCreated($order = Criteria::ASC) Order by the created column
 * @method DamagesCarDataQuery orderByModified($order = Criteria::ASC) Order by the modified column
 *
 * @method DamagesCarDataQuery groupById() Group by the id column
 * @method DamagesCarDataQuery groupByDealerId() Group by the dealer_id column
 * @method DamagesCarDataQuery groupByDealerParentId() Group by the dealer_parent_id column
 * @method DamagesCarDataQuery groupByDictBrandId() Group by the dict_brand_id column
 * @method DamagesCarDataQuery groupByName() Group by the name column
 * @method DamagesCarDataQuery groupByComissionNo() Group by the comission_no column
 * @method DamagesCarDataQuery groupByVin() Group by the vin column
 * @method DamagesCarDataQuery groupByLocked() Group by the locked column
 * @method DamagesCarDataQuery groupByCreated() Group by the created column
 * @method DamagesCarDataQuery groupByModified() Group by the modified column
 *
 * @method DamagesCarDataQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method DamagesCarDataQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method DamagesCarDataQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method DamagesCarDataQuery leftJoinDictBrands($relationAlias = null) Adds a LEFT JOIN clause to the query using the DictBrands relation
 * @method DamagesCarDataQuery rightJoinDictBrands($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DictBrands relation
 * @method DamagesCarDataQuery innerJoinDictBrands($relationAlias = null) Adds a INNER JOIN clause to the query using the DictBrands relation
 *
 * @method DamagesCarDataQuery leftJoinDealersRelatedByDealerId($relationAlias = null) Adds a LEFT JOIN clause to the query using the DealersRelatedByDealerId relation
 * @method DamagesCarDataQuery rightJoinDealersRelatedByDealerId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DealersRelatedByDealerId relation
 * @method DamagesCarDataQuery innerJoinDealersRelatedByDealerId($relationAlias = null) Adds a INNER JOIN clause to the query using the DealersRelatedByDealerId relation
 *
 * @method DamagesCarDataQuery leftJoinDealersRelatedByDealerParentId($relationAlias = null) Adds a LEFT JOIN clause to the query using the DealersRelatedByDealerParentId relation
 * @method DamagesCarDataQuery rightJoinDealersRelatedByDealerParentId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the DealersRelatedByDealerParentId relation
 * @method DamagesCarDataQuery innerJoinDealersRelatedByDealerParentId($relationAlias = null) Adds a INNER JOIN clause to the query using the DealersRelatedByDealerParentId relation
 *
 * @method DamagesCarDataQuery leftJoinCarDamages($relationAlias = null) Adds a LEFT JOIN clause to the query using the CarDamages relation
 * @method DamagesCarDataQuery rightJoinCarDamages($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CarDamages relation
 * @method DamagesCarDataQuery innerJoinCarDamages($relationAlias = null) Adds a INNER JOIN clause to the query using the CarDamages relation
 *
 * @method DamagesCarData findOne(PropelPDO $con = null) Return the first DamagesCarData matching the query
 * @method DamagesCarData findOneOrCreate(PropelPDO $con = null) Return the first DamagesCarData matching the query, or a new DamagesCarData object populated from the query conditions when no match is found
 *
 * @method DamagesCarData findOneById(int $id) Return the first DamagesCarData filtered by the id column
 * @method DamagesCarData findOneByDealerId(int $dealer_id) Return the first DamagesCarData filtered by the dealer_id column
 * @method DamagesCarData findOneByDealerParentId(int $dealer_parent_id) Return the first DamagesCarData filtered by the dealer_parent_id column
 * @method DamagesCarData findOneByDictBrandId(int $dict_brand_id) Return the first DamagesCarData filtered by the dict_brand_id column
 * @method DamagesCarData findOneByName(string $name) Return the first DamagesCarData filtered by the name column
 * @method DamagesCarData findOneByComissionNo(string $comission_no) Return the first DamagesCarData filtered by the comission_no column
 * @method DamagesCarData findOneByVin(string $vin) Return the first DamagesCarData filtered by the vin column
 * @method DamagesCarData findOneByLocked(int $locked) Return the first DamagesCarData filtered by the locked column
 * @method DamagesCarData findOneByCreated(string $created) Return the first DamagesCarData filtered by the created column
 * @method DamagesCarData findOneByModified(string $modified) Return the first DamagesCarData filtered by the modified column
 *
 * @method array findById(int $id) Return DamagesCarData objects filtered by the id column
 * @method array findByDealerId(int $dealer_id) Return DamagesCarData objects filtered by the dealer_id column
 * @method array findByDealerParentId(int $dealer_parent_id) Return DamagesCarData objects filtered by the dealer_parent_id column
 * @method array findByDictBrandId(int $dict_brand_id) Return DamagesCarData objects filtered by the dict_brand_id column
 * @method array findByName(string $name) Return DamagesCarData objects filtered by the name column
 * @method array findByComissionNo(string $comission_no) Return DamagesCarData objects filtered by the comission_no column
 * @method array findByVin(string $vin) Return DamagesCarData objects filtered by the vin column
 * @method array findByLocked(int $locked) Return DamagesCarData objects filtered by the locked column
 * @method array findByCreated(string $created) Return DamagesCarData objects filtered by the created column
 * @method array findByModified(string $modified) Return DamagesCarData objects filtered by the modified column
 *
 * @package    propel.generator.damages.om
 */
abstract class DamagesBaseCarDataQuery extends ModelCriteria
{
    /**
     * Initializes internal state of DamagesBaseCarDataQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_damages', $modelName = 'DamagesCarData', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new DamagesCarDataQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     DamagesCarDataQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return DamagesCarDataQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof DamagesCarDataQuery) {
            return $criteria;
        }
        $query = new DamagesCarDataQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   DamagesCarData|DamagesCarData[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = DamagesCarDataPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(DamagesCarDataPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   DamagesCarData A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, DEALER_ID, DEALER_PARENT_ID, DICT_BRAND_ID, NAME, COMISSION_NO, VIN, LOCKED, CREATED, MODIFIED FROM car_data WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new DamagesCarData();
            $obj->hydrate($row);
            DamagesCarDataPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return DamagesCarData|DamagesCarData[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|DamagesCarData[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(DamagesCarDataPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(DamagesCarDataPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(DamagesCarDataPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the dealer_id column
     *
     * Example usage:
     * <code>
     * $query->filterByDealerId(1234); // WHERE dealer_id = 1234
     * $query->filterByDealerId(array(12, 34)); // WHERE dealer_id IN (12, 34)
     * $query->filterByDealerId(array('min' => 12)); // WHERE dealer_id > 12
     * </code>
     *
     * @see       filterByDealersRelatedByDealerId()
     *
     * @param     mixed $dealerId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByDealerId($dealerId = null, $comparison = null)
    {
        if (is_array($dealerId)) {
            $useMinMax = false;
            if (isset($dealerId['min'])) {
                $this->addUsingAlias(DamagesCarDataPeer::DEALER_ID, $dealerId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dealerId['max'])) {
                $this->addUsingAlias(DamagesCarDataPeer::DEALER_ID, $dealerId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::DEALER_ID, $dealerId, $comparison);
    }

    /**
     * Filter the query on the dealer_parent_id column
     *
     * Example usage:
     * <code>
     * $query->filterByDealerParentId(1234); // WHERE dealer_parent_id = 1234
     * $query->filterByDealerParentId(array(12, 34)); // WHERE dealer_parent_id IN (12, 34)
     * $query->filterByDealerParentId(array('min' => 12)); // WHERE dealer_parent_id > 12
     * </code>
     *
     * @see       filterByDealersRelatedByDealerParentId()
     *
     * @param     mixed $dealerParentId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByDealerParentId($dealerParentId = null, $comparison = null)
    {
        if (is_array($dealerParentId)) {
            $useMinMax = false;
            if (isset($dealerParentId['min'])) {
                $this->addUsingAlias(DamagesCarDataPeer::DEALER_PARENT_ID, $dealerParentId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dealerParentId['max'])) {
                $this->addUsingAlias(DamagesCarDataPeer::DEALER_PARENT_ID, $dealerParentId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::DEALER_PARENT_ID, $dealerParentId, $comparison);
    }

    /**
     * Filter the query on the dict_brand_id column
     *
     * Example usage:
     * <code>
     * $query->filterByDictBrandId(1234); // WHERE dict_brand_id = 1234
     * $query->filterByDictBrandId(array(12, 34)); // WHERE dict_brand_id IN (12, 34)
     * $query->filterByDictBrandId(array('min' => 12)); // WHERE dict_brand_id > 12
     * </code>
     *
     * @see       filterByDictBrands()
     *
     * @param     mixed $dictBrandId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByDictBrandId($dictBrandId = null, $comparison = null)
    {
        if (is_array($dictBrandId)) {
            $useMinMax = false;
            if (isset($dictBrandId['min'])) {
                $this->addUsingAlias(DamagesCarDataPeer::DICT_BRAND_ID, $dictBrandId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dictBrandId['max'])) {
                $this->addUsingAlias(DamagesCarDataPeer::DICT_BRAND_ID, $dictBrandId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::DICT_BRAND_ID, $dictBrandId, $comparison);
    }

    /**
     * Filter the query on the name column
     *
     * Example usage:
     * <code>
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
     * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
     * </code>
     *
     * @param     string $name The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByName($name = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($name)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $name)) {
                $name = str_replace('*', '%', $name);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::NAME, $name, $comparison);
    }

    /**
     * Filter the query on the comission_no column
     *
     * Example usage:
     * <code>
     * $query->filterByComissionNo('fooValue');   // WHERE comission_no = 'fooValue'
     * $query->filterByComissionNo('%fooValue%'); // WHERE comission_no LIKE '%fooValue%'
     * </code>
     *
     * @param     string $comissionNo The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByComissionNo($comissionNo = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($comissionNo)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $comissionNo)) {
                $comissionNo = str_replace('*', '%', $comissionNo);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::COMISSION_NO, $comissionNo, $comparison);
    }

    /**
     * Filter the query on the vin column
     *
     * Example usage:
     * <code>
     * $query->filterByVin('fooValue');   // WHERE vin = 'fooValue'
     * $query->filterByVin('%fooValue%'); // WHERE vin LIKE '%fooValue%'
     * </code>
     *
     * @param     string $vin The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByVin($vin = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($vin)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $vin)) {
                $vin = str_replace('*', '%', $vin);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::VIN, $vin, $comparison);
    }

    /**
     * Filter the query on the locked column
     *
     * Example usage:
     * <code>
     * $query->filterByLocked(1234); // WHERE locked = 1234
     * $query->filterByLocked(array(12, 34)); // WHERE locked IN (12, 34)
     * $query->filterByLocked(array('min' => 12)); // WHERE locked > 12
     * </code>
     *
     * @param     mixed $locked The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByLocked($locked = null, $comparison = null)
    {
        if (is_array($locked)) {
            $useMinMax = false;
            if (isset($locked['min'])) {
                $this->addUsingAlias(DamagesCarDataPeer::LOCKED, $locked['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($locked['max'])) {
                $this->addUsingAlias(DamagesCarDataPeer::LOCKED, $locked['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::LOCKED, $locked, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(DamagesCarDataPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(DamagesCarDataPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query on the modified column
     *
     * Example usage:
     * <code>
     * $query->filterByModified('2011-03-14'); // WHERE modified = '2011-03-14'
     * $query->filterByModified('now'); // WHERE modified = '2011-03-14'
     * $query->filterByModified(array('max' => 'yesterday')); // WHERE modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $modified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function filterByModified($modified = null, $comparison = null)
    {
        if (is_array($modified)) {
            $useMinMax = false;
            if (isset($modified['min'])) {
                $this->addUsingAlias(DamagesCarDataPeer::MODIFIED, $modified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($modified['max'])) {
                $this->addUsingAlias(DamagesCarDataPeer::MODIFIED, $modified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesCarDataPeer::MODIFIED, $modified, $comparison);
    }

    /**
     * Filter the query by a related DamagesDictBrands object
     *
     * @param   DamagesDictBrands|PropelObjectCollection $dictBrands The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesCarDataQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDictBrands($dictBrands, $comparison = null)
    {
        if ($dictBrands instanceof DamagesDictBrands) {
            return $this
                ->addUsingAlias(DamagesCarDataPeer::DICT_BRAND_ID, $dictBrands->getId(), $comparison);
        } elseif ($dictBrands instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesCarDataPeer::DICT_BRAND_ID, $dictBrands->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDictBrands() only accepts arguments of type DamagesDictBrands or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DictBrands relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function joinDictBrands($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DictBrands');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DictBrands');
        }

        return $this;
    }

    /**
     * Use the DictBrands relation DictBrands object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDictBrandsQuery A secondary query class using the current class as primary query
     */
    public function useDictBrandsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinDictBrands($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DictBrands', 'DamagesDictBrandsQuery');
    }

    /**
     * Filter the query by a related DamagesDealers object
     *
     * @param   DamagesDealers|PropelObjectCollection $dealers The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesCarDataQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDealersRelatedByDealerId($dealers, $comparison = null)
    {
        if ($dealers instanceof DamagesDealers) {
            return $this
                ->addUsingAlias(DamagesCarDataPeer::DEALER_ID, $dealers->getId(), $comparison);
        } elseif ($dealers instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesCarDataPeer::DEALER_ID, $dealers->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDealersRelatedByDealerId() only accepts arguments of type DamagesDealers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DealersRelatedByDealerId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function joinDealersRelatedByDealerId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DealersRelatedByDealerId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DealersRelatedByDealerId');
        }

        return $this;
    }

    /**
     * Use the DealersRelatedByDealerId relation Dealers object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDealersQuery A secondary query class using the current class as primary query
     */
    public function useDealersRelatedByDealerIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinDealersRelatedByDealerId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DealersRelatedByDealerId', 'DamagesDealersQuery');
    }

    /**
     * Filter the query by a related DamagesDealers object
     *
     * @param   DamagesDealers|PropelObjectCollection $dealers The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesCarDataQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByDealersRelatedByDealerParentId($dealers, $comparison = null)
    {
        if ($dealers instanceof DamagesDealers) {
            return $this
                ->addUsingAlias(DamagesCarDataPeer::DEALER_PARENT_ID, $dealers->getId(), $comparison);
        } elseif ($dealers instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesCarDataPeer::DEALER_PARENT_ID, $dealers->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByDealersRelatedByDealerParentId() only accepts arguments of type DamagesDealers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the DealersRelatedByDealerParentId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function joinDealersRelatedByDealerParentId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('DealersRelatedByDealerParentId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'DealersRelatedByDealerParentId');
        }

        return $this;
    }

    /**
     * Use the DealersRelatedByDealerParentId relation Dealers object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesDealersQuery A secondary query class using the current class as primary query
     */
    public function useDealersRelatedByDealerParentIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinDealersRelatedByDealerParentId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'DealersRelatedByDealerParentId', 'DamagesDealersQuery');
    }

    /**
     * Filter the query by a related DamagesCarDamages object
     *
     * @param   DamagesCarDamages|PropelObjectCollection $carDamages  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesCarDataQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByCarDamages($carDamages, $comparison = null)
    {
        if ($carDamages instanceof DamagesCarDamages) {
            return $this
                ->addUsingAlias(DamagesCarDataPeer::ID, $carDamages->getCarDataId(), $comparison);
        } elseif ($carDamages instanceof PropelObjectCollection) {
            return $this
                ->useCarDamagesQuery()
                ->filterByPrimaryKeys($carDamages->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByCarDamages() only accepts arguments of type DamagesCarDamages or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the CarDamages relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function joinCarDamages($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('CarDamages');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'CarDamages');
        }

        return $this;
    }

    /**
     * Use the CarDamages relation CarDamages object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesCarDamagesQuery A secondary query class using the current class as primary query
     */
    public function useCarDamagesQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinCarDamages($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'CarDamages', 'DamagesCarDamagesQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   DamagesCarData $carData Object to remove from the list of results
     *
     * @return DamagesCarDataQuery The current query, for fluid interface
     */
    public function prune($carData = null)
    {
        if ($carData) {
            $this->addUsingAlias(DamagesCarDataPeer::ID, $carData->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
